package com.pets.springboot_petshop.mapper;

import com.pets.springboot_petshop.entity.Pettype;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface PettypeMapper {
    @Select("select * from pettype where id = #{id};")
    Pettype selectPettype(int id);

    @Select("SELECT * FROM pettype WHERE name = #{name}")
    Pettype selectPettypename(String name);

    @Select("SELECT id FROM pettype WHERE name = #{pettypeName}")
    int selectName(String pettypeName);

    @Select("select * from pettype;")
    List<Pettype> findAll();

    @Insert("insert into pettype(name,description,img,create_time,update_time)values(#{name},#{description},#{img},now(),now());")
    int addPettype(Pettype pettype);

    @Delete("delete from pettype where id=#{id};")
    int deletePettypeById(int id);

    @Update("UPDATE pettype SET name=#{name},description=#{description},img=#{img},update_time=now() where id= #{id};")
    int updatePettypeById(Pettype pettype);
}